﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Xna.Framework.Audio;


namespace wp7CattoFreeAppv2
{
   
    /// <summary> K8 App Bar Example
    /// K8 App Bar Example
    /// </summary>
    public partial class K8AppBar : PhoneApplicationPage
    {

        SoundEffect effect;
        SoundEffectInstance seInstance;

        /// <summary>
        ///  K8 App Bar
        /// </summary>
        public K8AppBar()
        {
            InitializeComponent();

            this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;

            ApplicationBar = new ApplicationBar();
            ApplicationBar.IsMenuEnabled = true;
            ApplicationBar.IsVisible = true;
            ApplicationBar.Opacity = 1.0;


            ApplicationBarIconButton hide = new ApplicationBarIconButton(new Uri("/images/expand.png", UriKind.Relative));
            hide.Text = "hide";
            hide.Click += new EventHandler(hide_Click);

            // #37 for the winner devfish raffle -- whoo ha won a bag
            ApplicationBarIconButton opacity = new ApplicationBarIconButton(new Uri("/images/opacity.png", UriKind.Relative));
            opacity.Text = "opacity";
            opacity.Click += new EventHandler(opacity_Click);

            ApplicationBarIconButton enabled = new ApplicationBarIconButton(new Uri("/images/menuenabled.png", UriKind.Relative));
            enabled.Text = "enabled";
            enabled.Click += new EventHandler(enabled_Click);

            ApplicationBar.Buttons.Add(hide);
            ApplicationBar.Buttons.Add(opacity);
            ApplicationBar.Buttons.Add(enabled);

            ApplicationBarMenuItem foregroundItem = new ApplicationBarMenuItem("use foreground color");
            //foregroundItem.Click += new EventHandler(foregroundItem_Click);

            //ApplicationBarMenuItem accentItem = new ApplicationBarMenuItem("use accent color");
            //accentItem.Click += new EventHandler(accentItem_Click);

            //ApplicationBar.MenuItems.Add(foregroundItem);
            //ApplicationBar.MenuItems.Add(accentItem);



            UpdateText();
        }
        #region "Methods"
            void UpdateText()
            {
                //VisibleTextBlock.Text = ApplicationBar.IsVisible ? "yes" : "no";
                //OpacityTextBlock.Text = ApplicationBar.Opacity.ToString("0.0");
                //MenuEnabledTextBlock.Text = ApplicationBar.IsMenuEnabled ? "yes" : "no";
            }




        #endregion
        #region "Events"
            
            private void btnMainMenu_Click(object sender, RoutedEventArgs e)
            {
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }

            /// <summary> opacity_Click 
            /// opacity_Click
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            void opacity_Click(object sender, EventArgs e)
            {
                if (ApplicationBar.Opacity < .01)
                {
                    ApplicationBar.Opacity = 1;
                }
                else if (ApplicationBar.Opacity > .49 && ApplicationBar.Opacity < .51)
                {
                    ApplicationBar.Opacity = 0;
                }
                else
                {
                    ApplicationBar.Opacity = .5;
                }
                UpdateText();
            }

            void hide_Click(object sender, EventArgs e)
            {
                ApplicationBar.IsVisible = false;
                //showButton.Visibility = Visibility.Visible;
                UpdateText();
            }


            /// <summary> /// Button Show App Bar Click
            /// Button Show App Bar Click
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btnShowAppBar_Click(object sender, RoutedEventArgs e)
            {
                //ApplicationBar.IsVisible = true;
                //showButton.Visibility = Visibility.Collapsed;
                //UpdateText();
            }

            /// <summary>enabled_Click
            /// enabled_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
            void enabled_Click(object sender, EventArgs e)
            {
                ApplicationBar.IsMenuEnabled = !ApplicationBar.IsMenuEnabled;
                UpdateText();
            }

        #endregion




    }
}